//
//  Common.swift
//  SwiftDemo
//
//  Created by xxcao on 2016/12/12.
//  Copyright © 2016年 xxcao. All rights reserved.
//


import UIKit
import Foundation

class Common: NSObject {
    class func removeExtraCellLines(TableView table:UITableView){
        //除去TableView多余分割线
        let view : UIView = UIView.init()
        view.backgroundColor = UIColor.clear
        table.tableFooterView = view;
    }
    
    
    //自定义push动画
    class func customPushAnimationFromNavigation(nav:UINavigationController, toViewController vc :UIViewController, type: String, subType: String, duration: Double) {
        let transition:CATransition = CATransition()
        transition.duration = duration
        transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
        transition.type = type
        transition.subtype = subType;
        nav.view.layer.add(transition, forKey: nil)
        nav.pushViewController(vc, animated: false)
    }
    
    //自定义pop动画
    class func customPopAnimationFromNavigation(nav: UINavigationController, type: String, subType: String, duration: Double) {
        let transition:CATransition = CATransition()
        transition.duration = duration
        transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
        transition.type = type;
        transition.subtype = subType;
        nav.view.layer.add(transition, forKey: nil)
        nav.popViewController(animated: false)
    }
    
    class func isAllNum(str:String) -> Bool {
        let scan: Scanner = Scanner(string: str)
        var val:Int = 0
        return scan.scanInt(&val) && scan.isAtEnd
    }
    
    class func getCurrentDate() -> String  {
        let date = NSDate()
        let dateFormatter = DateFormatter()
        dateFormatter.dateFormat = "yyyy-MM-dd"
        return dateFormatter.string(from: date as Date)
    }
    
    class func getCurrentTime() -> String  {
        let date = NSDate()
        let dateFormatter = DateFormatter()
        dateFormatter.dateFormat = "HH:mm"
        return dateFormatter.string(from: date as Date)
    }
    
    static func configureType(type: String) -> String {
        if CommonFunc.validate(withStartTime: "05:00", withExpireTime: "09:30", withTiem: type) {
            return "早上"
        }
        if CommonFunc.validate(withStartTime: "11:00", withExpireTime: "14:00", withTiem: type)  {
            return "中午"
        }
        if CommonFunc.validate(withStartTime: "17:00", withExpireTime: "20:30", withTiem: type)  {
            return "晚上"
            
        }
        return "其它"
    }
    
}



/*
 animation.type = kCATransitionFade;
 animation.type = kCATransitionPush;
 animation.type = kCATransitionReveal;
 animation.type = kCATransitionMoveIn;
 animation.type = @"cube";
 animation.type = @"suckEffect";
 animation.type = @"oglFlip";
 animation.type = @"rippleEffect";
 animation.type = @"pageCurl";
 animation.type = @"pageUnCurl";
 animation.type = @"cameraIrisHollowOpen";
 animation.type = @"cameraIrisHollowClose";
 */

